Skip to content

Add parallel test execution for local development#2598

Open
mroderick wants to merge 3 commits intocodebar:masterfrom
mroderick:parallel-test-execution
Open

Add parallel test execution for local development#2598
mroderick wants to merge 3 commits intocodebar:masterfrom
mroderick:parallel-test-execution

Conversation

@mroderick
Copy link
Copy Markdown
Collaborator

Summary

This PR introduces parallel test execution for local development, significantly reducing test runtime.

Changes

1. Added make test target to Makefile

Runs tests in parallel using 3 processes (optimal for this codebase):

bundle exec parallel_rspec spec/ -n 3

2. Made SimpleCov conditional on COVERAGE environment variable

  • SimpleCov is now only enabled when COVERAGE=true
  • Speeds up local test runs by avoiding coverage overhead
  • Prevents coverage file conflicts when running parallel tests locally
  • CI already has COVERAGE=true set, so coverage reporting continues to work

3. Added parallel test support for coverage merging

When TEST_ENV_NUMBER is set (by parallel_tests gem) or CI_NODE_INDEX (GitHub Actions), coverage results are properly namespaced for merging.

4. Updated AGENTS.md documentation

  • Recommends make test for parallel test execution
  • Notes that SimpleCov only runs when COVERAGE=true
  • Fixed outdated bin/drspec reference

Performance Results

Command Time Improvement
bundle exec rspec ~3m2s (182s) baseline
make test ~1m39s (99s) ~45% faster

Usage

# Run all tests in parallel (recommended)
make test

# Or run directly with parallel_rspec
bundle exec parallel_rspec spec/ -n 3

# Run single test (no parallelization needed)
bundle exec rspec spec/path/to/file_spec.rb:42

# Run with coverage (local)
COVERAGE=true bundle exec rspec

Notes

  • The -n 3 (3 processes) was chosen as optimal for this codebase. Higher values don't provide significant additional speedup due to database contention.
  • CI already uses parallel test execution across 6 matrix jobs, so no changes needed there.

Only enable SimpleCov when COVERAGE=true is set. This:
- Speeds up local test runs (no coverage overhead)
- Avoids coverage file conflicts when running parallel tests locally
- Allows parallel test execution without coverage merging complexity

Coverage is still enabled in CI by setting COVERAGE=true in the workflow.

Also adds proper parallel test support for coverage merging when
TEST_ENV_NUMBER is set (by parallel_tests gem) or CI_NODE_INDEX
(for GitHub Actions matrix strategy).
Set COVERAGE=true in GitHub Actions workflow to enable SimpleCov
coverage reporting in CI. This works with the conditional SimpleCov
loading in spec_helper.rb.
@mroderick mroderick requested a review from olleolleolle April 26, 2026 21:18
@mroderick mroderick marked this pull request as ready for review April 26, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant